package main

import "fmt"

//iota常量计数器
//iota是go语言的常量计数器，只能在常量的表达式中使用
//在const关键字出现时将被重置为0。
//const中每新增一行常量声明将使iota计数+1  （注意是每一行的声明都会+1）
const (
	a1 = iota //0
	a2        //1
	a3        //2
)

//匿名量接收  跳过
const (
	_  = iota //0
	b1        //1
	b2        //2
	b3        //3
)

//插队  继续计数
const (
	_  = iota //0
	c1        //1
	c2 = 100  //100
	c3        //100
	c4        //100
	c5 = iota //5
	c6        //6
)

func main() {
	fmt.Println(a1, a2, a3)
	fmt.Println(b1, b2, b3)
	fmt.Println(c1, c2, c3, c4, c5, c6)

	//iota结合运算
	const (
		_  = iota
		KB = 1 << (10 * iota)
		MB = 1 << (10 * iota)
		GB = 1 << (10 * iota)
		TB = 1 << (10 * iota)
	)

	//多个iota定义在同一行
	const (
		a, b = iota, iota + 1 //0 1	(新声明一行 才会+1)
		c, d                  //1 2
		e, f                  //2 3
	)

	fmt.Println(KB, MB, GB, TB)
	fmt.Println(a, b, c, d, e, f)
}
